package whf.framework.security.dao;

import java.util.List;
import java.util.Map;

import whf.framework.exception.FindException;
import whf.framework.security.entity.User;
import whf.framework.util.Utils;

/**
 * @author wanghaifeng
 * @email king@126.com
 * @modify 2006-05-31
 */
public class UserDAOImp extends whf.framework.dao.DAOImp<User> implements UserDAO {
	public User findByUsernamePassword(String username, String password) throws FindException {
		Map<String, Object> props = Utils.newHashMap();
		props.put("username", username);
		props.put("password", password);
		List<User> users = super.findByProperties(props,0, Integer.MAX_VALUE);
		if(users.size() > 0){
			return users.get(0);
		}else {
			return null;
		}
	}

	public User findByUsername(String username) throws FindException{
		Map<String, Object> props = Utils.newHashMap();
		props.put("username", username);
		List<User> users = super.findByProperties(props,0, Integer.MAX_VALUE);
		if(users.size() > 0){
			return users.get(0);
		}else {
			return null;
		}
	}
} 